from selenium.webdriver.common.by import By
from common.base import Base
import time



class  Centrol(Base):
    # 登录成功后的页面
    def themain(self):
        # 切换frame
        self.driver.switch_to.frame('menu-frame')
        time.sleep(1)
        # 商品管理
        self.click((By.XPATH, '//li[@key="02_cat_and_goods"]'))
        time.sleep(1)
        # 添加新商品
        self.click((By.LINK_TEXT, '添加新商品'))
        time.sleep(2)
        # 切换frame,返回主页面
        self.driver.switch_to.default_content()
        time.sleep(2)
        # 切换frame
        self.driver.switch_to.frame('main-frame')
    # 跳转到其他信息
    def themain1(self):
        self.click((By.XPATH,'//div[@id="tabbar-div"]/p/span[@id="mix-tab"]'))
    # 获取第一个商品名称
    def themain2(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('main-frame')
        return self.get_text((By.CSS_SELECTOR, '#listDiv > table:nth-child(1) > tbody > tr:nth-child(3) > td.first-cell > span'))


